/*
 * G2P_NGram.h
 *
 *  Created on: Nov 24, 2012
 *      Author: bannok
 */

#ifndef G2P_TONEGRAM_H_
#define G2P_TONEGRAM_H_
#include "dictionary_tool.h"
#include "g2p_syllable_tree.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <string>

#define TONE_N_GRAM_PROB_MAX 60000
#define TONE_N_GRAM_DTONE_MAX 60000

typedef struct _tone_node{
	syllable_seq_unit * syl;
	int st_n;
	struct _tone_node * parent;
	struct _tone_node * child;
	int p_tone[6];
	float mem_prob[20];
	int mem_tone[20];
	int tone_prob_size;
	int tone_count;
	int select_tone;
	float max_prob;
	bool r;
}tone_node;

typedef struct _tone_bi_struct{
	float p;
	float bo;
}tone_bi_struct;

typedef struct _tone_struct{
	int tone;
}tone_struct;

int tone_ngram_prob_load_bin(const char* input);
int tone_ngram_prob_load_dict(char * fn);
float tone_ngram_calculate(char * st1,char * st2);

int tone_ngram_pattern_load_bin( char * input);
int tone_ngram_pattern_load_dict( char * input);
int tone_ngram_pattern_seach(char * st);

int tone_ngram_seach(char * st);

tone_node * tone_ngram_create_node();
int tone_ngram_free_node(tone_node * ntone );

#endif /* G2P_NGRAM_H_ */
